TEX = tex
INCLUDE = include
SRCCODE = codepic/code
SRCPIC	= codepic/pic
SRCDIA	= pictures
SRCUML	= uml
SRCUMBRELLO = uml/uml.xmi

SYSA_BIN = ../distsyst/sysa/bin
TESTS_SRC = ../distsyst/sysa/src/sys/tests
TESTS_BIN = ../distsyst/sysa/bin/sys/tests

PDF=rpz.pdf
S2L=./src2tex
D2T=dot2tex -f tikz  --figonly
PDFLATEX = pdflatex -interaction=nonstopmode

.PHONY: clean proposal
proposal: $(PDF)

$(INCLUDE)/%.ex.tex: $(SRCCODE)/%.ex
	$(S2L) $< >  $@	

# ЕПС в ПДФ
# Отдельно для автоматов
$(INCLUDE)/sys/fsm/graph/%_dia.pdf: $(INCLUDE)/sys/fsm/graph/%_dia.eps
	epstopdf $< --outfile=$@
# Для остального
$(INCLUDE)/%_dia.pdf: $(SRCPIC)/%_dia.eps
	epstopdf $< --outfile=$@

$(INCLUDE)/%_umbrello.pdf: $(INCLUDE)/%_umbrello.eps
	epstopdf $< --outfile=$@

$(INCLUDE)/%_research.pdf: $(INCLUDE)/%.eps
	epstopdf $< --outfile=$@

# ДИА в ЕПС
# Специально для автоматов
$(INCLUDE)/sys/fsm/graph/%_dia.eps:$(INCLUDE)/sys/fsm/graph/%.dia 
	dia -e $@ -t eps-pango $<
# Для остального
$(SRCPIC)/%_dia.eps:$(SRCDIA)/%.dia 
	dia -e $@ -t eps-pango $<

# Получение епс из амбрелло
$(INCLUDE)/%_umbrello.eps:$(SRCUMBRELLO) 
	#umbrello --export eps --directory $(INCLUDE) $<

$(INCLUDE)/%.gv.tex: $(SRCDIA)/%.gv
	$(D2T) $<  > $@

# Листинги тестов
$(INCLUDE)/test/%.test.tex: $(TESTS_BIN)/%.test
	$(S2L) $< >  $@	

$(INCLUDE)/test/%.java.tex: $(TESTS_SRC)/%.java
	$(S2L) $< >  $@	

$(PDF) : $(addprefix $(TEX)/, rpz.tex introduction.tex analytics.tex construct.tex technological.tex research.tex biblio.tex) \
$(addprefix $(INCLUDE)/, architecture_dia.pdf conceptual_dia.pdf er_dia.pdf use_case2_umbrello.pdf use_case3_umbrello.pdf use_case4_umbrello.pdf sequence1_umbrello.pdf sequence2_umbrello.pdf sequence3_umbrello.pdf sequence4_umbrello.pdf statechart1_umbrello.pdf statechart2_umbrello.pdf test/automat/result.test.tex test/automat/AutomatTest.java.tex test/logic/result.test.tex test/logic/LogicTest.java.tex sys/fsm/graph/Automat1_sm_dia.pdf sys/fsm/graph/Automat2_sm_dia.pdf research/3_research.pdf research/4_research.pdf research/5_research.pdf research/6_research.pdf research/7_research.pdf research/8_research.pdf research/9_research.pdf research/10_research.pdf research/11_research.pdf research/12_research.pdf research/linearNet_research.pdf research/prolog5funcs_research.pdf research/prolog7funcs_research.pdf research/prolog8funcs_research.pdf research/prolog10funcs_research.pdf research/prolog9funcs_research.pdf research/linearNet2_research.pdf research/linearNet3_research.pdf Automat.ex.tex configA.ex.tex configS.ex.tex Makefile.ex.tex jsonmessage.ex.tex prolog.ex.tex genSetGeneration.ex.tex neuralGnuplot.ex.tex drawneuro.ex.tex)
	cd $(TEX) && $(PDFLATEX) rpz.tex && cp $(PDF) ..

clean:
	rm $(INCLUDE)/* ; find $(TEX)/ -type f ! -name "*.tex" -exec rm -f {} \;
